<template>
  <j-modal-demo
    :footer="null"
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form class="ant-advanced-search-form" :form="form">
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-item label="姓　　名" >
              <a-input v-decorator="['professorInfo.professorName']" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="性　　别">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorSex']" :trigger-change="true" dictCode="sex" placeholder="请选择专家性别" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="出生年月">
              <j-date placeholder="请选择出生年月" v-decorator="['professorInfo.professorBirthday']" :trigger-change="true" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="照片" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-image-upload v-decorator="['professorInfo.professorPhotoString']" disabled></j-image-upload>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="毕业院校">
              <j-dict-select-tag  type="list" v-decorator="['professorInfo.professorSchool']" :trigger-change="true" dictCode="school" placeholder="请选择毕业院校" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="所学专业">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorMajor']" :trigger-change="true" dictCode="school" placeholder="请选择所学专业" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item  label="毕业时间">
              <j-date placeholder="请选择毕业时间" v-decorator="['professorInfo.professorGraduateDate']" :trigger-change="true" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="学　　历">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorEducationBackground']" :trigger-change="true" dictCode="school" placeholder="请选择学历" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="学　　位">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorDegree']" :trigger-change="true" dictCode="school" placeholder="请选择学位" disabled/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item label="工作单位">
              <a-input v-decorator="['professorInfo.professorWorkUnit']" placeholder="请输入工作单位" disabled></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="16">
            <a-form-item label="通讯地址">
              <a-input v-decorator="['professorInfo.professorAddress']" placeholder="请输入通讯地址" disabled></a-input>          </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="申报类别">
              <a-textarea  :rows="1" v-decorator="['professorInfo.type']" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="职　　务">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorPosition']" :trigger-change="true" dictCode="school" placeholder="请选择职务" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="参加工作时间">
              <j-date placeholder="请选择参加工作时间" v-decorator="['professorInfo.professorBeginWork']" :trigger-change="true" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="技术职称">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorTitle']" :trigger-change="true" dictCode="school" placeholder="请选择技术职称" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="从事专业">
              <a-input v-decorator="['professorInfo.professorWorkMajor']" placeholder="请输入从事专业" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="从事专业时间">
              <j-date placeholder="请选择从事专业时间" v-decorator="['professorInfo.professorMajorDate']" :trigger-change="true" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="身份证号">
              <a-input v-decorator="['professorInfo.professorIdentity']" placeholder="请输入身份证号" disabled></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="16">
            <a-form-item label="家庭地址">
              <j-area-linkage type="cascader" v-decorator="['professorInfo.professorHomeAddress']" placeholder="请输入省市区" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="健康状态">
              <j-dict-select-tag type="list" v-decorator="['professorInfo.professorHealth']" :trigger-change="true" dictCode="school" placeholder="请选择健康状况" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="办公室联系方式">
              <a-input addon-before="" v-decorator="['professorInfo.professorOfficeTel']" disabled/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="手机联系方式">
              <a-input addon-before="手机" v-decorator="['professorInfo.professorPhone']" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item label="">
              <span>本人支持或参加过的典型项目（包括项目名称、建设规模、投资额及所负责的内容）</span>
              <a-textarea  :rows="4" v-decorator="['professorInfo.professorProjectIntroduce']" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item>
              <span>业务主管部门</span>
              <a-textarea :rows="4" v-decorator="['professorInfo.professorLeadMsg']" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item >
              <span>行政审批局意见</span>
              <a-textarea :rows="4" v-decorator="['professorInfo.professorApproveMsg']" disabled/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="18">
            <a-form-item >
              <a-input v-decorator="['professorTableId']" hidden="hidden" disabled/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-if="title==='审核'">
          <a-button type="primary" :style="{ marginLeft: '400px'}" @click="handleOk">
            通过
          </a-button>
          <a-button :style="{ marginLeft: '10px'}" @click="refuse">
            拒绝
          </a-button>
        </a-row>
      </a-form>
    </a-spin>
  </j-modal-demo>
</template>

<script>

  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import JImageUpload from '@/components/jeecg/JImageUpload'
  import JDictSelectTag from "@/components/dict/JDictSelectTag"
  import JCategorySelect from '@/components/jeecg/JCategorySelect'
  import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
  import {postAction} from '@/api/manage'
  export default {
    name: "DiyTableStatusModal",
    components: {
      JDate,
      JImageUpload,
      JDictSelectTag,
      JAreaLinkage,
      JCategorySelect,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:1000,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          refuse:"/org/diyTableStatus/checker?check=false",
          accept: "/org/diyTableStatus/checker?check=true",
          edit: "/org/diyTableStatus/edit",
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'professorInfo','professorInfo.professorAddress','createBy','createTime','updateBy','updateTime','professorTableId','tableStatus','checkerId'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        let proTId = that.form.getFieldValue("professorTableId");
        // alert(proTId)
        let theUrl = this.url.accept+"&professorTableId="+proTId;
        postAction(theUrl).then((res)=>{
          if(res.success){
            that.$message.success(res.message);
            that.$emit('ok');
          }else{
            that.$message.error(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
          that.close();
        });

      },
      handleCancel () {
        this.close()
      },
      refuse () {
        const that = this;
        // 触发表单验证
        let proTId = that.form.getFieldValue("professorTableId");
        // alert(proTId)
        let theUrl = this.url.refuse+"&professorTableId="+proTId;
        postAction(theUrl).then((res)=>{
          if(res.success){
            that.$message.success(res.message);
            that.$emit('ok');
          }else{
            that.$message.error(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
          that.close();
        });
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'professorInfo','professorInfo.professorAddress','createBy','createTime','updateBy','updateTime','professorTableId','tableStatus','checkerId'))
      },


    }
  }
</script>